package com.asa.physics;

import com.asa.physics.bean.Point;

public class NormFunc {

	/**
	 * 空间中一个面
	 */
	public static double mian(double x,double y,double A,double B,double C,double D) {
		return (A*x+B*y+D)/(-C);
	}
	/**
	 * 根据两个向量确定一个面的参数
	 * 用的是上面ABCD
	 * @return
	 */
	public static double[] mian2f(Point p,Point q,double x0,double y0,double z0) {
		
		double A = p.y*q.z-q.y*p.z;
		double B = -(p.x*q.z-q.x*p.z);
		double C = p.x*q.y-q.x*p.y;
		double D = -(A*x0+B*y0+C*z0);
		double[] asa = {A,B,C,D};
		return asa;
	}
	
	/**
	 * 球面方程，对应每一对xy有两个z值
	 * @param R
	 * @param x0
	 * @param y0
	 * @param z0
	 * @param x
	 * @param y
	 * @return
	 */
	public static double[] qiu(double R,double x0,double y0,double z0,double x,double y) {
		double[] zs = new double[2];
		double asa = Math.sqrt(R*R-((x-x0)*(x-x0)+(y-y0)*(y-y0)));
		zs[0] = z0 + asa;
		zs[1] = z0 - asa;
		return zs;
	}
	
	
	
	
	
	
	
	
	
	
}
